package _嗖嗖移动大厅2_0.A3_0;

import java.io.*;
import java.net.Socket;
import java.util.Objects;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        InputStream is = null;
        OutputStream os = null;
        BufferedReader br = null;
        PrintWriter pw = null;
        try {
            Socket socket = new Socket("192.168.1.161", 8888);
            is = socket.getInputStream();
            os = socket.getOutputStream();
            br = new BufferedReader(new InputStreamReader(is));
            pw = new PrintWriter(os);
            while (true) {
                String s = "";
                while (!Objects.equals(s = br.readLine(), "")) {
                    System.out.println(s);
                }
                String s1 = input.nextLine();
                pw.println(s1);
                pw.flush();
                if ( Objects.equals(s1, "end")){
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
                if (os != null) {
                    os.close();
                }
                if (br != null) {
                    is.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
